<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>moment(Number[]) | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>moment(Number[])</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>moment(Number[])</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/parsing/array/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/01-parsing/10-array.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment(Number[]);
</code></pre>

							</div>
<p>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x6570;&#x503C;&#x7684;&#x6570;&#x7EC4;&#xFF08;&#x6620;&#x5C04;&#x4F20;&#x7ED9; <a href="javascript:window.open('http://nodejs.cn/s/AtSkg7');" target="_blank" rel="nofollow">new Date()</a> &#x7684;&#x53C2;&#x6570;&#xFF09;&#x6765;&#x521B;&#x5EFA; moment&#x3002;</p>
<p><code>[year, month, day, hour, minute, second, millisecond]</code></p>
<pre><code class="language-javascript">moment([2010, 1, 14, 15, 25, 50, 125]); // February 14th, 3:25:50.125 PM
</code></pre>
<p>&#x5E74;&#x4EFD;&#x4E4B;&#x540E;&#x7684;&#x4EFB;&#x4F55;&#x503C;&#x90FD;&#x662F;&#x53EF;&#x9009;&#x7684;&#xFF0C;&#x5E76;&#x4E14;&#x9ED8;&#x8BA4;&#x4E3A;&#x53EF;&#x80FD;&#x7684;&#x6700;&#x5C0F;&#x503C;&#x3002;</p>
<pre><code class="language-javascript">moment([2010]);        // January 1st
moment([2010, 6]);     // July 1st
moment([2010, 6, 10]); // July 10th
</code></pre>
<p>&#x4F7F;&#x7528;&#x6570;&#x7EC4;&#x7684;&#x6784;&#x9020;&#x5C06;&#x4F1A;&#x5728;&#x5F53;&#x524D;&#x65F6;&#x533A;&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x65E5;&#x671F;&#x3002;
&#x82E5;&#x8981;&#x4ECE; UTC &#x6570;&#x7EC4;&#x521B;&#x5EFA;&#x65E5;&#x671F;&#xFF0C;&#x5219;&#x4F7F;&#x7528; <code>moment.utc(Number[])</code>&#x3002;</p>
<pre><code class="language-javascript">moment.utc([2010, 1, 14, 15, 25, 50, 125]);
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF1A;&#x56E0;&#x4E3A;&#x8FD9;&#x6620;&#x5C04;&#x4E86;&#x539F;&#x751F;&#x7684; <code>Date</code> &#x53C2;&#x6570;&#xFF0C;&#x6240;&#x4EE5;&#x6708;&#x4EFD;&#xFF0C;&#x5C0F;&#x65F6;&#xFF0C;&#x5206;&#x949F;&#xFF0C;&#x79D2;&#x949F;&#x3001;&#x6BEB;&#x79D2;&#x90FD;&#x662F;&#x96F6;&#x7D22;&#x5F15;&#x7684;&#x3002;
&#x5E74;&#x4EFD;&#x3001;&#x6708;&#x4EFD;&#x7684;&#x65E5;&#x671F;&#x5219;&#x662F; 1 &#x7D22;&#x5F15;&#x7684;&#x3002;</p>
<p>&#x8FD9;&#x901A;&#x5E38;&#x662F;&#x6DF7;&#x4E71;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x5C24;&#x5176;&#x662F;&#x6708;&#x4EFD;&#xFF0C;&#x56E0;&#x6B64;&#x8BF7;&#x6CE8;&#x610F;&#xFF01;</p>
<p>&#x5982;&#x679C;&#x6570;&#x7EC4;&#x4EE3;&#x8868;&#x7684;&#x65E5;&#x671F;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x5219; <code>moment#isValid</code> &#x5C06;&#x4F1A;&#x8FD4;&#x56DE; false&#x3002;</p>
<pre><code class="language-javascript">moment([2010, 12]).isValid();     // false&#xFF08;&#x4E0D;&#x662F;&#x771F;&#x5B9E;&#x7684;&#x6708;&#x4EFD;&#xFF09;
moment([2010, 10, 31]).isValid(); // false&#xFF08;&#x4E0D;&#x662F;&#x771F;&#x5B9E;&#x7684;&#x65E5;&#x671F;&#xFF09;
moment([2010, 1, 29]).isValid();  // false&#xFF08;&#x4E0D;&#x662F;&#x95F0;&#x5E74;&#xFF09;
</code></pre>
					</div>
          <div id="content_right">
							<div class="docs-method-signature">
								<pre><code class="language-js">moment(Number[]);
</code></pre>

							</div>
<p>You can create a moment with an array of numbers that mirror the parameters passed to <a href="javascript:window.open('https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date');" target="_blank" rel="nofollow">new Date()</a></p>
<p><code>[year, month, day, hour, minute, second, millisecond]</code></p>
<pre><code class="language-javascript">moment([2010, 1, 14, 15, 25, 50, 125]); // February 14th, 3:25:50.125 PM
</code></pre>
<p>Any value past the year is optional, and will default to the lowest possible number.</p>
<pre><code class="language-javascript">moment([2010]);        // January 1st
moment([2010, 6]);     // July 1st
moment([2010, 6, 10]); // July 10th
</code></pre>
<p>Construction with an array will create a date in the current time zone. To create a date from an array at UTC, use <code>moment.utc(Number[])</code>.</p>
<pre><code class="language-javascript">moment.utc([2010, 1, 14, 15, 25, 50, 125]);
</code></pre>
<p><strong>Note:</strong> Because this mirrors the native <code>Date</code> parameters, months, hours, minutes, seconds, and milliseconds are all zero indexed. Years and days of the month are 1 indexed.</p>
<p>This is often the cause of frustration, especially with months, so take note!</p>
<p>If the date represented by the array does not exist, <code>moment#isValid</code> will return false.</p>
<pre><code class="language-javascript">moment([2010, 12]).isValid();     // false (not a real month)
moment([2010, 10, 31]).isValid(); // false (not a real day)
moment([2010, 1, 29]).isValid();  // false (not a leap year)
</code></pre>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>